package com.zsy.test.nio;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;

/**
 * @author: zsy
 * @date: 2020/12/22 9:48
 */
public class ReadFiles {
    static ArrayList<String> keys = new ArrayList<>();
    static ArrayList<String> values = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        String a1 = "en-US";
        String a2 = "zh-CN";
        String path = "E:\\jrx-projects\\anytxn-acquirer-cms-front\\src\\locales\\" + a2 + "\\parameter\\message.js";
        Files.lines(Paths.get(path)).forEach(ReadFiles::getArray);

        keys.forEach(System.out::println);
        System.out.println("***********************");
        values.forEach(System.out::println);
    }

    private static void getArray(String line) {
        if (line.contains("//")) {

        } else if (line.contains(": '")) {
            String[] split = line.split(": '");
            keys.add(split[0].trim());
            values.add(split[1].replace("'", "").replace(",", "").trim());
        } else if (line.contains(":'")) {
            String[] split = line.split(":'");
            keys.add(split[0].trim());
            values.add(split[1].replace("'", "").replace(",", "").trim());
        } else if (line.contains(":\t'")) {
            String[] split = line.split(":\t'");
            keys.add(split[0].trim());
            values.add(split[1].replace("'", "").replace(",", "").trim());
        }
    }
}
